<template>
  <div class="shop-box">
    <div class="select">
      <el-checkbox
        v-model="select_id"
        :true-label="shop.shop_id"
        :false-label="''"
        @change="$emit('select', shop.shop_id, select_id)"
      ></el-checkbox>
    </div>
    <div class="shop-item">
      <img :src="shop.shop_img" alt="" />
      <div class="info">
        <div class="name">
          <b>{{ shop.shop_name }}</b>
          <button @click="clearShopsAttent">取消关注</button>
        </div>
        <div class="attention">{{ shop.shop_collection }}人关注</div>
        <div class="detailed">
          <div class="item">
            所有商品<span> {{ shop.shop_goods }}</span>
          </div>
          <div class="item">
            新品<span> {{ shop.shop_new }}</span>
          </div>
          <div class="item">
            促销<span> {{ shop.shop_promotion }}</span>
          </div>
        </div>
      </div>
    </div>
    <div class="goods-list">
      <GoodsItem8
        :goods="item"
        v-for="(item, index) in shop.good"
        :key="index"
      />
    </div>
  </div>
</template>

<script>
import api from "@/api";
import GoodsItem8 from "@/components/GoodsItem/GoodsItem8.vue";
export default {
  name: "ShopItem2",
  components: { GoodsItem8 },
  props: {
    shop: Object,
    select: {
      type: Boolean,
      default: false,
    },
  },
  watch: {
    select() {
      if (this.select) {
        this.select_id = this.shop.shop_id;
      } else {
        this.select_id = "";
      }
    },
  },
  data() {
    return {
      select_id: "",
    };
  },
  methods: {
    clearShopsAttent() {
      api
        .SHOPS_COLLECTION({ shop_id: this.shop.shop_id, status: 0 })
        .then(() => {
          this.$emit("refresh");
        });
    },
  },
};
</script>

<style lang="scss" scoped>
.shop-box {
  width: 960px;
  height: 204px;
  border-radius: 5px;
  border: 1px solid #f0f0f0;
  display: flex;
  margin-bottom: 20px;
  .select {
    padding: 59px 16px 0 20px;
    font-size: 0;
  }
  .shop-item {
    width: 448px;
    height: 134px;
    box-sizing: border-box;
    background: #ffffff;
    border-radius: 5px;
    display: inline-block;
    position: relative;
    display: flex;
    margin-top: 20px;
    img {
      width: 94px;
      height: 94px;
      border-radius: 2px;
      margin-right: 20px;
    }
    .info {
      flex: 1;
      width: 0;
      .name {
        display: flex;
        align-items: center;
        b {
          font-size: 18px;
          font-weight: 600;
          color: #333333;
          line-height: 25px;
        }
        button {
          cursor: pointer;
          margin-left: 20px;
          width: 120px;
          box-sizing: border-box;
          height: 28px;
          background: #d52c1a;
          border-radius: 5px;
          border: 1px solid #d52c1a;
          color: #fff;
        }
      }
      .attention {
        padding: 10px 0;
        font-size: 16px;
        font-weight: 400;
        color: #999999;
        line-height: 22px;
      }
      .detailed {
        font-size: 0;
        font-weight: 400;
        color: #666666;
        line-height: 22px;
        .item {
          font-size: 16px;
          display: inline-block;
          margin-left: 20px;
          &:first-child {
            margin-left: 0;
          }
          span {
            padding-left: 10px;
            color: #dc2c1a;
          }
        }
      }
    }
  }
  .goods-list {
    flex: 1;
    width: 0;
    margin-top: 20px;
    & > div:first-child {
      margin-left: 0;
    }
  }
}
</style>
